package com.jic.data.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.jic.data.constant.consist.ResponseCode;
import com.jic.data.exception.AppRuntimeException;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import javax.annotation.Resource;
import java.math.BigDecimal;
import com.jic.data.model.vo.response.SaleStructureDataResponse;
import com.jic.data.model.entity.SaleStructureData;
import com.jic.data.mapper.SaleStructureDataMapper;
import com.jic.data.service.SaleStructureDataService;

import lombok.extern.slf4j.Slf4j;
/**
 * 接口实现类
 *
 * @author : 建投数据科技(山东)有限公司
 * @version : v1.0.0
 * @email :
 * @since : 2020-03-09 10:12:20
 */
@Service
@Slf4j
public class SaleStructureDataServiceImpl implements SaleStructureDataService {

	@Resource
	private SaleStructureDataMapper mapper;


	/**
	 * 销售结构-销售结构明细数据
	 *
	 * @param request 不分页查询入参实体类
	 * @return 数据库查到的实体类列表
	 */
	@Override
	public List<SaleStructureDataResponse> listAllRecord(SaleStructureData request) {

		List<SaleStructureData> list = mapper.selectBySelective(request);

		List<SaleStructureDataResponse> responseList = list.stream().map(temp -> {
			SaleStructureDataResponse bo = new SaleStructureDataResponse();
			BeanUtils.copyProperties(temp, bo);
			int orderProductQuantity = temp.getProductQuantity().intValue()/temp.getTotalOrderQuantity().intValue();
			bo.setOrderProductQuantity(orderProductQuantity);
			return bo;
		}).filter(item -> item != null).collect(Collectors.toList());

		return responseList;
	}




}
